home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / swaga-c / copymove.swg / 0011_Move File #2.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  789b  |  40 lines

  1. {
  2. > How would I move a File from within my Program.
  3.  
  4. if the File is to moved from & to the same partition,
  5. all you have to do is:
  6.  
  7.   Assign(F,OldPath);
  8.   Rename(F,NewPath);
  9.  
  10. On the other hand, if the File is to be moved to a different
  11. partition, you will have to copy / erase the File.
  12. Example:
  13. }
  14. Program MoveFile;
  15.  
  16. Var
  17.   fin,fout  : File;
  18.   p         : Pointer;
  19.   w         : Word;
  20.  
  21. begin
  22.   GetMem(p,64000);
  23.   Assign(fin,ParamStr(1));               { Assumes command line parameter. }
  24.   Assign(fout,ParamStr(2));
  25.   Reset(fin);
  26.   ReWrite(fout);
  27.   While not Eof(fin) do
  28.   begin
  29.     BlockRead(fin,p^,64000,w);
  30.     BlockWrite(fout,p^,w);
  31.   end;
  32.   Close(fin);
  33.   Close(fout);
  34.   Erase(fin);
  35.   FreeMem(p,64000);
  36. end.
  37.  
  38. {
  39. This Program has NO error control.
  40. }